/**
 * Copyright (c) 2016-2019  All rights reserved.
 * <p>
 *
 * <p>
 * 版权所有，侵权必究！
 */

package io.yuncheng.common.config;

import io.yuncheng.common.utils.Constant;
import io.yuncheng.common.utils.SysDictConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Filter配置
 *
 * @author Mark sunlightcs@gmail.com
 */
@Configuration
public class SystemLevelConfig {


    @Resource
    private DictConfig config;

    @Bean
    public SystemLevel buildSysLevel() {
        SystemLevel systemLevel = new SystemLevel();
        systemLevel.setSysLevelEnum(Constant.SysLevelEnum.PROVINCE);
        String sysDictValue = config.getSysDictValue(SysDictConstant.SYS_LEVEL, Constant.DICT_DEFAULT_CODE);
        if (Integer.valueOf(sysDictValue) != Constant.SysLevelEnum.PROVINCE.getValue()) {
            systemLevel.setSysLevelEnum(Constant.SysLevelEnum.CITY);
        }
        return systemLevel;
    }

    public class SystemLevel {
        private Constant.SysLevelEnum sysLevelEnum;

        public Constant.SysLevelEnum getSysLevelEnum() {
            return sysLevelEnum;
        }

        public void setSysLevelEnum(Constant.SysLevelEnum sysLevelEnum) {
            this.sysLevelEnum = sysLevelEnum;
        }

    }
}
